package group.program.register.username;

import group.program.Controller.RegisterController;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.MockitoAnnotations;
import static org.junit.jupiter.api.Assertions.*;

class length {
    @InjectMocks
    private RegisterController registerController;

    @BeforeEach
    void setUp() {
        MockitoAnnotations.openMocks(this);
    }

    @Test
    void testValidateUserNameLength_ValidLength() {
        String validUserName = "John";
        assertNull(registerController.validateUserNameLength(validUserName));
    }

    @Test
    void testValidateUserNameLength_TooShort() {
        String shortUserName = "Jo";
        assertEquals("用户名长度必须大于等于4位，小于10位", registerController.validateUserNameLength(shortUserName));
    }

    @Test
    void testValidateUserNameLength_TooLong() {
        String longUserName = "JohnDoeSmith";
        assertEquals("用户名长度必须大于等于4位，小于10位", registerController.validateUserNameLength(longUserName));
    }
}
